/**
 * 手机号码验证
 * @param _ 
 * @param mobile 
 * @param callback 
 * @returns 
 */
export function validatorMobile(_: any, value: string, callback: (error?: string | Error) => void, message?: string) {
  const reg = /^1[3-9]\d{9}$/;
  if (!reg.test(value)) {
    callback(new Error(message || "手机号格式错误"));
  }
  callback();
}

/**
 * 邮箱校验
 * @param _ 
 * @param email 
 * @param callback 
 * @returns 
 */
export function validatorEmail(_: any, email: string, callback: (error?: string | Error) => void, message?: string) {
  const reg = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  if (email.trim() !== "" && !reg.test(email)) {
    callback(new Error(message || "邮箱格式错误"));
  }
  callback();
}